/*
 *   Copyright 1999-2016 Asiainfo Technologies(China),Inc.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
package com.asiainfo.redis.scheduling;

import org.quartz.JobDetail;
import org.quartz.listeners.SchedulerListenerSupport;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author william.xu
 * @version $Id: SchedulerListener.java,v 1.1 2013/06/18 09:12:20 xuwz Exp $
 * Created on 2013-5-27 下午2:19:40
 */

@Component("schedulerListener")
public class SchedulerListener extends SchedulerListenerSupport {

	private static List<Map<String,String>> jobList = new ArrayList<Map<String, String>>();
	
	public static List<Map<String, String>> getJobList() {
		return jobList;
	}

	public static void setJobList(List<Map<String, String>> jobList) {
		SchedulerListener.jobList = jobList;
	}

	public void jobAdded(JobDetail jobDetail) {
		String desc = jobDetail.getDescription(); 
		if ( desc != null){
			Map<String, String> map = new HashMap<String, String>();
			map.put("name", jobDetail.getKey().getName());
			map.put("description", desc);
			jobList.add(map);
		}
    }

}
